//
//  RecommendTalbleCell.m
//  CommonFrame
//
//  Created by Bang-guo on 15/7/16.
//  Copyright (c) 2015年 guobang. All rights reserved.
//

#import "RecommendTalbleCell.h"
#import <UIImageView+WebCache.h>

@implementation RecommendTalbleCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubViews];
        
    }
    
    return self;
}

-(void)createSubViews {
    
    self.backgrountImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, WIDTH - 20, 200)];
//    self.backgrountImageView.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.backgrountImageView];

    self.backgrountImageView.layer.cornerRadius = 10;
    self.backgrountImageView.layer.masksToBounds = YES;
    
}

-(void)setRecommmendScroll:(RecommendScroll *)recommmendScroll {
    
    if (_recommmendScroll != recommmendScroll) {
        
        _recommmendScroll = recommmendScroll;
        
    }
    if ([recommmendScroll.type isEqualToString:@"4"]) {
        
//        [self.backgrountImageView sd_setImageWithURL:[NSURL URLWithString:recommmendScroll.cover_image]];
        [self.backgrountImageView sd_setImageWithURL:[NSURL URLWithString:recommmendScroll.cover_image] placeholderImage:[UIImage imageNamed:@"icon1024.png"]];

        NSString *isOK = [NSString stringWithFormat:@"%@", recommmendScroll.is_featured_trip];
        if ([isOK isEqualToString:@"1"]) {
            
            BaseLabel *selectL = [[BaseLabel alloc] initWithFrame:CGRectMake(WIDTH - 70, 10, 40, 25)];
            selectL.backgroundColor = [UIColor orangeColor];
            selectL.text = @"精选";
            selectL.textAlignment = NSTextAlignmentCenter;
            selectL.font = [UIFont boldSystemFontOfSize:15];
            selectL.textColor = [UIColor whiteColor];
            [self.backgrountImageView addSubview:selectL];
            
        }
        
        BaseLabel *nameL = [[BaseLabel alloc] initWithFrame:CGRectMake(10, 10, WIDTH - 70, 30)];
        nameL.text = recommmendScroll.name;
        nameL.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:nameL];
        nameL.font = [UIFont boldSystemFontOfSize:17];
        
        BaseLabel *blueL = [[BaseLabel alloc] initWithFrame:CGRectMake(nameL.frame.origin.x, nameL.frame.origin.y + 30, 3, 30)];
        blueL.backgroundColor = [UIColor blueColor];
        [self.backgrountImageView addSubview:blueL];
        
        BaseLabel *firstL = [[BaseLabel alloc] initWithFrame:CGRectMake(nameL.frame.origin.x + 7, nameL.frame.origin.y + 30, WIDTH - 70, 15)];
        NSString *str = [NSString stringWithFormat:@"%@ %@天 %@次浏览", recommmendScroll.first_day, recommmendScroll.day_count, recommmendScroll.view_count];
        firstL.text = str;
        firstL.font = [UIFont boldSystemFontOfSize:13.0];
        firstL.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:firstL];
        
        BaseLabel *secondL = [[BaseLabel alloc] initWithFrame:CGRectMake(nameL.frame.origin.x + 7, firstL.frame.origin.y + 15, WIDTH - 70, 15)];
        secondL.text = recommmendScroll.popular_place_str;
        secondL.font = [UIFont boldSystemFontOfSize:13.0];
        secondL.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:secondL];
        
        
        UIImageView *userImage = [[UIImageView alloc] initWithFrame:CGRectMake(nameL.frame.origin.x, self.backgrountImageView.frame.size.height - 40, 30, 30)];
        userImage.layer.masksToBounds = YES;
        userImage.layer.cornerRadius = 15;
        [userImage sd_setImageWithURL:[NSURL URLWithString:recommmendScroll.avatar_m]];
        [self.backgrountImageView addSubview:userImage];
        
        BaseLabel *userL = [[BaseLabel alloc] initWithFrame:CGRectMake(nameL.frame.origin.x + 33, self.backgrountImageView.frame.size.height - 40, WIDTH - 70, 30)];
        userL.text = recommmendScroll.userName;
        userL.font = [UIFont boldSystemFontOfSize:15.0];
        userL.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:userL];
        
    }
    if ([recommmendScroll.type isEqualToString:@"5"] ) {
        BaseView *viewBackground = [[BaseView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        viewBackground.backgroundColor = [UIColor blackColor];
        viewBackground.alpha = 0.3;
        [self.backgrountImageView addSubview:viewBackground];
        [self.backgrountImageView sd_setImageWithURL:[NSURL URLWithString:recommmendScroll.cover]];
        
        BaseLabel *titleLable = [[BaseLabel alloc] initWithFrame:CGRectMake(0, 50, WIDTH, 30)];
        titleLable.textAlignment = NSTextAlignmentCenter;
        titleLable.font = [UIFont boldSystemFontOfSize:20];
        titleLable.text = recommmendScroll.cover_title;
        titleLable.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:titleLable];
        
        BaseLabel *subTitleLable = [[BaseLabel alloc] initWithFrame:CGRectMake(0, 90, WIDTH, 30)];
        subTitleLable.textAlignment = NSTextAlignmentCenter;
        subTitleLable.font = [UIFont systemFontOfSize:14];
        NSString *str = [NSString stringWithFormat:@"[   %@   ]", recommmendScroll.cover_sub_title];
        subTitleLable.text = str;
        subTitleLable.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:subTitleLable];
        subTitleLable.font = [UIFont boldSystemFontOfSize:17];

    }
    if ([recommmendScroll.type isEqualToString:@"7"] || [recommmendScroll.type isEqualToString:@"6"]) {
        BaseView *viewBackground = [[BaseView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        viewBackground.backgroundColor = [UIColor blackColor];
        viewBackground.alpha = 0.3;
        [self.backgrountImageView addSubview:viewBackground];
        [self.backgrountImageView sd_setImageWithURL:[NSURL URLWithString:recommmendScroll.cover]];
        
        BaseLabel *titleLable = [[BaseLabel alloc] initWithFrame:CGRectMake(0, 50, WIDTH, 30)];
        titleLable.textAlignment = NSTextAlignmentCenter;
        titleLable.font = [UIFont boldSystemFontOfSize:20];
        titleLable.text = recommmendScroll.title;
        titleLable.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:titleLable];
        
        
        BaseLabel *subTitleLable = [[BaseLabel alloc] initWithFrame:CGRectMake(0, 90, WIDTH, 30)];
        subTitleLable.textAlignment = NSTextAlignmentCenter;
        subTitleLable.font = [UIFont boldSystemFontOfSize:14];
        NSString *str = [NSString stringWithFormat:@"[   %@   ]", recommmendScroll.sub_title];
        subTitleLable.text = str;
        subTitleLable.textColor = [UIColor whiteColor];
        [self.backgrountImageView addSubview:subTitleLable];
        
    }
    
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
